import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'commercialBankReportM',
  state: {
    openModeList: [],
  },

  effects: {
    //获取前一交易日
    *getTradingDate({ payload, callback }, { call, put }) {
      const res = yield call(api.getTradingDate, payload);
      if (res && res.message == 'success') {
        callback(res.data);
      } else {
        callback();
        message.error(res?.message);
      }
    },

    //
    *getZcByYenant({ payload, callback }, { call, put }) {
      const res = yield call(api.commercialBankReport.getZcByYenant, payload);
      if (res && res.msg == 'success') {
        callback(res.data);
      } else {
        callback();
        message.error(res?.msg);
      }
    },

    *getFBBondInvestment({ payload, callback }, { call, put }) {
      const res = yield call(api.commercialBankReport.getFBBondInvestment, payload);
      if (res && res.msg == 'success') {
        callback(res);
      } else {
        callback();
        message.error((res && res.msg) || '请求错误');
      }
    },

    //集中度管理
    *getConcentrationManagement({ payload, callback }, { call, put }) {
      const res = yield call(api.commercialBankReport.getConcentrationManagement, payload);
      if (res && res.msg == 'success') {
        callback(res.data);
      } else {
        callback();
        message.error((res && res.msg) || '请求错误');
      }
    },

    //杠杆率
    *getLeverageRatio({ payload, callback }, { call, put }) {
      const res = yield call(api.commercialBankReport.getLeverageRatio, payload);
      if (res && res.msg == 'success') {
        callback(res.data);
      } else {
        callback();
        message.error((res && res.msg) || '请求错误');
      }
    },
    //流动性 a
    *getMobilityManagement({ payload, callback }, { call, put }) {
      const res = yield call(api.commercialBankReport.getMobilityManagement, payload);
      if (res && res.msg == 'success') {
        callback(res?.data);
      } else {
        message.error((res && res.msg) || '请求错误');
      }
    },
  },
  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
